import {
  defineComponent,
  useCssVars,
  ref,
  computed,
  watch,
  onMounted,
  resolveDirective,
  withDirectives,
  openBlock,
  createElementBlock,
  createTextVNode,
  toDisplayString,
  unref
} from "vue";
import {
  b as useProp,
  u as useCanvasState,
  j as useData,
  k as useEventBus,
  _ as _export_sfc
} from "./index-CEDaTd93.js";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "SubText",
  props: {
    component: {}
  },
  setup(__props) {
    useCssVars(_ctx => ({
      "94d2a4dc": lineHeight.value
    }));
    const singValue = ref();
    const props = __props;
    const { propValue } = useProp(props.component);
    const customeText = ref("0");
    const lineHeight = ref("20px");
    const resizeHandler = entry => {
      const { height } = entry.contentRect;
      lineHeight.value = `${height}px`;
    };
    const canvasState = useCanvasState();
    const dataChange = (resp, _) => {
      singValue.value = resp.afterData;
      dataHandler();
    };
    useData(props.component, dataChange);
    const dataHandler = () => {
      if (
        propValue.base.tag &&
        typeof canvasState.globalData.data != "undefined"
      ) {
        customeText.value = canvasState.globalData.data[propValue.base.tag];
      } else if (singValue.value) {
        var mykey = Object.keys(singValue.value);
        customeText.value = singValue.value[mykey[0]];
      }
    };
    const myTag = computed(() => {
      return propValue.base.tag;
    });
    watch(myTag, () => {
      dataHandler();
    });
    onMounted(async () => {});
    useEventBus("globalData", dataHandler);
    return (_ctx, _cache) => {
      const _directive_resize = resolveDirective("resize");
      return withDirectives(
        (openBlock(),
        createElementBlock("span", null, [
          createTextVNode(
            toDisplayString(
              unref(propValue).base.label
                ? `${unref(propValue).base.label}:`
                : ""
            ) +
              " " +
              toDisplayString(customeText.value) +
              " " +
              toDisplayString(unref(propValue).base.unit),
            1
          )
        ])),
        [[_directive_resize, resizeHandler]]
      );
    };
  }
});
const SubText = /* @__PURE__ */ _export_sfc(_sfc_main, [
  ["__scopeId", "data-v-6f13742d"]
]);
export { SubText as default };
